package com.zhou.sys.common.sso.common.captcha.utils.encoder;

import com.zhou.sys.common.sso.common.captcha.service.Captcha;
import com.zhou.sys.common.sso.common.captcha.service.CaptchaService;

import javax.imageio.ImageIO;


import java.io.IOException;
import java.io.OutputStream;

/**
 * 验证码编码辅助类
 */
public class EncoderHelper {

	public static String getChallangeAndWriteImage(CaptchaService service, String format, OutputStream os) throws IOException {
		Captcha captcha = service.getCaptcha();
		ImageIO.write(captcha.getImage(), format, os); 
		return captcha.getChallenge();
	}
	
}

